﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using COM.PreAlarm.Model;
using COM.PreAlarm.BLL;
using System.Data;
using System.Web.UI.WebControls;

public partial class Pages_Equip_Installed_Edit : ZMPageEdit<Equip_Installed, Equip_InstalledInfo>
{
    #region 重写方法

    protected override void OnLoading()
    {
        base.OnLoading();

        if (!IsPostBack)
        {
            if (IsNewModel) {
                Equip_InstalledInfo_Equip_InstallDate.Value = DateTime.Now.ToString("yyyy-MM-dd");
               
            }

            //初始化市
            MdlistInfo _MdlistInfo = new MdlistInfo();
            _MdlistInfo.TranType = "GetCityByUser";
            _MdlistInfo.UID = ZASession.Account;

            DataTable dt = Mdlist.GetDataTableByModel(_MdlistInfo);
            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    //hidCity.Value = dt.Rows.co
                    hidCity.Value = hidCity.Value + dr["name"] + ',';
                }
            }

            BindFactory_No();
        }
    }

    protected override void OnAchieve()
    {
        if (IsNewModel)
        {
            //获取编号
            Equip_Installed Equip_Installed = new COM.PreAlarm.BLL.Equip_Installed();
            List<DBParameter> _listDBParameter = new List<DBParameter>();
            _listDBParameter.Add(new DBParameter("@District", Equip_InstalledInfo_Equip_County.Value));
            _listDBParameter.Add(new DBParameter("@Equip_Class", StringHelper.FormatBlankStringToint(Equip_InstalledInfo_Equip_Class.SelectedValue)));
            _listDBParameter.Add(new DBParameter("@Factory_NO", Equip_InstalledInfo_Factory_No.SelectedValue));
            Model.Equip_No = StringHelper.FormatObjToString(Equip_Installed.ExecuteScalar("[dbo].[GetEquipNO]", _listDBParameter, System.Data.CommandType.StoredProcedure));
            Equip_InstalledInfo_Equip_SimNo.Value = Equip_InstalledInfo_Equip_SimNo.Value.Trim();

        }
        base.OnAchieve();
    }

  


    protected void BindFactory_No()
    {

        MdlistInfo _MdlistInfo = new MdlistInfo();
        _MdlistInfo.TranType = "Factory_No";
        ZABinder.FillList(string.Empty, Equip_InstalledInfo_Factory_No, true, Mdlist.GetDataTableByModel(_MdlistInfo));

        _MdlistInfo.Type = "Equip_Class";
        ZABinder.FillList(string.Empty, Equip_InstalledInfo_Equip_Class, false, Mdlist.GetListByType(_MdlistInfo));

        _MdlistInfo.Type = "Equip_SendMode";
        ZABinder.FillList(string.Empty, Equip_InstalledInfo_Equip_SendMode, false, Mdlist.GetListByType(_MdlistInfo));

    }

    protected override void OnBinding()
    {
        base.OnBinding();
        if (!IsNewModel)
        {
            
            ZABinder.SetSelected(Equip_InstalledInfo_Factory_No, Model.Factory_No, Model.Factory_No);
            ZABinder.SetSelected(Equip_InstalledInfo_Equip_Class,StringHelper.FormatObjToString(Model.Equip_Class), StringHelper.FormatObjToString(Model.Equip_Class));
            ZABinder.SetSelected(Equip_InstalledInfo_Equip_SendMode, StringHelper.FormatObjToString(Model.Equip_SendMode), StringHelper.FormatObjToString(Model.Equip_SendMode));
        }


    }




    #endregion 	重写方法
}